import service from "@/api/index.js";
import qs from "qs";

const adminApi = {
    //添加
    insert(admin){
        return service.post("/admin",admin);
    },
    //删除
    delete(id){
        return service.delete(`/admin/${id}`);
    },
    //修改
    update(admin){
        return service.put("/admin",admin);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/admin",{
            params: condition
        });
    },
    //根据id搜索
    selectById(id){
        return service.get(`/admin/${id}`);
    },
    //获取验证码
    captcha() {
       return  service.get("/admin/captcha");
    },
    //登录
    login(admin) {
        return service.post("/admin/login", qs.stringify(admin))
    },
    //获取已经登录信息
    getInfo(){
        return service.get("/admin/info")
    },
    //获取已经登录信息
    chgPwd(chgPwdObj){
        return service.put("/admin/chgPwd",qs.stringify(chgPwdObj))
    }
}

export default adminApi;